package com.magiccompass.alipay.barcode.zdummy;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.Criteria;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service("dummyDao")
public class DummyDAOImpl implements DummyDAO {
	@Resource(name="sessionFactory")
	private SessionFactory sessionFactory;
	 
    public DummyDAOImpl() {
    }
    
	@Override
	@Transactional
	public List<DummyData> list() {
		 @SuppressWarnings("unchecked")
	        List<DummyData> listUser = (List<DummyData>) sessionFactory.getCurrentSession()
	                .createCriteria(DummyData.class)
	                .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list();
	 
	        return listUser;
	}
	
	@Override
	@Transactional
	public void addDummyData(DummyData dummyData){
		sessionFactory.getCurrentSession().save(dummyData);
	}

}
